﻿Public Class FormFiltreRegEx

  
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        FormBrowser.WebBrowser1.DocumentText = My.Resources.RegExHelp
        FormBrowser.Show()
    End Sub




    Private Sub SousMasque1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque1ToolStripMenuItem.Click
        AjouterMasqueREP("$1")
    End Sub

    Private Sub SousMasque2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque2ToolStripMenuItem.Click
        AjouterMasqueREP("$2")
    End Sub

    Private Sub SousMasque3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque3ToolStripMenuItem.Click
        AjouterMasqueREP("$3")
    End Sub

    Private Sub CeQuiVientAvantLeMasqueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CeQuiVientAvantLeMasqueToolStripMenuItem.Click
        AjouterMasqueREP("$`")
    End Sub

    Private Sub CeQuiVientAprèsLeMasqueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CeQuiVientAprèsLeMasqueToolStripMenuItem.Click
        AjouterMasqueREP("$'")
    End Sub

    Private Sub ToutLeMasqueToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToutLeMasqueToolStripMenuItem.Click
        AjouterMasqueREP("$&")
    End Sub

    Private Sub DernierSubmatchToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DernierSubmatchToolStripMenuItem.Click
        AjouterMasqueREP("$+")
    End Sub

    Private Sub SousMasque4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque4ToolStripMenuItem.Click
        AjouterMasqueREP("$4")
    End Sub

    Private Sub SousMasque5ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque5ToolStripMenuItem.Click
        AjouterMasqueREP("$5")
    End Sub

    Private Sub SousMasque6ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque6ToolStripMenuItem.Click
        AjouterMasqueREP("$6")
    End Sub

    Private Sub SousMasque7ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque7ToolStripMenuItem.Click
        AjouterMasqueREP("$7")
    End Sub

    Private Sub SousMasque8ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque8ToolStripMenuItem.Click
        AjouterMasqueREP("$8")
    End Sub

    Private Sub SousMasque9ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SousMasque9ToolStripMenuItem.Click
        AjouterMasqueREP("$9")
    End Sub

    Private Sub AjouterMasqueREP(ByVal Masque As String)
        Me.TextBox2.SelectedText = Masque
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim oTrans As New ClassTextOp
        oTrans.Operation = ClassTextOp.EnumTextOperation.RemplacerRegEx
        oTrans.Parametres(0) = Me.ComboBox1.Text
        oTrans.Parametres(1) = Me.TextBox2.Text
        Me.RichTextBoxResult.Text = oTrans.Transformer(Me.RichTextBox1.Text)
        oTrans = Nothing
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.ContextMenuReplace.Show(Me.Button1, New System.Drawing.Point(0, 0))
    End Sub

  
  
    Private Sub FormFiltreRegEx_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        Me.ComboBox1.Items.Clear()
        For Each oItem In Form1.ListViewMarqueurs.Items
            Me.ComboBox1.Items.Add(oItem.Tag.Masque)
        Next
    End Sub

    Private Sub Button12_Click(sender As System.Object, e As System.EventArgs) Handles Button12.Click
        FormRegEx.TextBoxRegEx.Text = Me.ComboBox1.Text
        FormRegEx.RichTextBoxTest.Text = RichTextBox1.Text
        If FormRegEx.ShowDialog = DialogResult.OK Then
            Me.ComboBox1.Text = FormRegEx.TextBoxRegEx.Text
            Me.RichTextBox1.Text = FormRegEx.RichTextBoxTest.Text
        End If
    End Sub
End Class